package com.tarim.streetdance.service.impl;

import com.tarim.streetdance.mapper.CommentStairMapper;
import com.tarim.streetdance.model.CommentStair;
import com.tarim.streetdance.service.CommentSecondService;
import com.tarim.streetdance.service.CommentStairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class CommentStairServiceImpl implements CommentStairService {

    @Autowired
    private CommentStairMapper commentStairMapper;
    @Autowired
    private CommentSecondService commentSecondService;

    @Override
    public int insertSelective(CommentStair commentStair) {
        commentStair.setCreateTime(new Date());
        commentStair.setDr(0);
        return commentStairMapper.insertSelective(commentStair);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int updateForDelete(CommentStair commentStair) {
        commentSecondService.updateForDeleteSecond(commentStair);
        return commentStairMapper.updateForDelete(commentStair);
    }
}